﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VCC.Site.ViewModels;
using VCC.Site.Properties;
using VCC.Model;
using MyUtility;
using System.IO;
using VCC.Lib.Common;
namespace VCC.Site.Controllers
{
    public class HomeController : Controller
    {

        ChoVietDataContext eDataContext = new ChoVietDataContext();
        public ActionResult Index()
        {
            if (HttpContext.Session["CreatedAdSucc"] != null && !string.IsNullOrEmpty(HttpContext.Session["CreatedAdSucc"].ToString()))
            {
                string[] ms = HttpContext.Session["CreatedAdSucc"].ToString().Split(';');
                string messTemp = Settings.Default.SiteRootPath + "MessageTemplates\\CreatedAdSucc.htm";
                string bodyFomat = MyFile.ReadFile(messTemp);
                string bodyMess = string.Format(bodyFomat,ms[0],ms[1],ms[2],ms[3]);
                ViewData[Messages.MessageTopInfo] = MessageType.Message + bodyMess;
                HttpContext.Session.Remove("CreatedAdSucc");
            }
            return View();
        }
        [ChildActionOnly]
        public ActionResult BoxCategories()
        {
            BoxCategoriesModel model = new BoxCategoriesModel();
            model.Domain = Settings.Default.Domain;
            model.ParentCategory = eDataContext.Categories.Where(e => e.PubYN == true && e.ParentID == null).OrderBy(e => e.Priority).ToList();
            return View(model);
        }
        public ActionResult About()
        {
            return View();
        }
    }
}
